# -*- coding: utf-8 -*-
# @Author : HaleShi
# @Time : 2023-07-03
# @File : 12_v.8.6.3_frida-rpc.py

import frida

str_host = "127.0.0.1:8877"
manager = frida.get_device_manager()
rdev = manager.add_remote_device(str_host)
# rdev = frida.get_remote_device()
pid = rdev.spawn(["com.yoloho.dayima"])
session = rdev.attach(pid)

scr = """
rpc.exports = {   
    sign:function(j2,str,j3){
         var res;

         Java.perform(function () {

            // 包.类
            var Crypt = Java.use("com.yoloho.libcore.util.Crypt");

            // 类中的方法
            res = Crypt.encrypt_data(j2,str,j3);
         });

         return res;
    }
}
"""

script = session.create_script(scr)
script.load()
rdev.resume(pid)

sign = script.exports.sign(0, "3e56104c8b41fc4db7a72972e298fa711bf0135euser/login18378353331Pneqv/aCWUxlagDjPcT1oQ==",
                           85)
print(sign)

# device 3e56104c8b41fc4db7a72972e298fa711bf0135e